import request from '@/utils/request'

// 获取楼宇信息
export function getBuildingList (data) {
  return request({
    url: '/dormitoryBuilding/getPageList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 新增楼宇
export function addBuilding (data) {
  return request({
    url: '/dormitoryBuilding/saveBuild',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 查询校区名称
export function getCampusName (data) {
  return request({
    url: '/campus/getCampusList',
    method: 'post',
    params: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 获取楼宇名
export function getBuildingName (data) {
  return request({
    url: '/dormitoryBuilding/getBuildList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 获取楼长姓名
export function getAdminName (data) {
  return request({
    url: '/merchantAdmin/getBuildingChiefList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 修改楼宇信息
export function updateBuilding (data) {
  return request({
    url: '/dormitoryBuilding/update',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 删除楼宇信息
export function deleteBuilding (data) {
  return request({
    url: '/dormitoryBuilding/delete',
    method: 'post',
    params: data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 导出楼宇信息
export function exportBuilding (data) {
  return request({
    url: '/dormitoryBuilding/export',
    method: 'post',
    data: data,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 导入楼宇信息
export function uploadBuilding (data) {
  return request({
    url: '/dormitoryBuilding/upload',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}

// 下载楼宇信息模板
export function downLoadBuilding (data) {
  return request({
    url: '/dormitoryBuilding/downLoadExcel',
    method: 'post',
    data: data,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': window.localStorage.getItem('token'),
    }
  })
}
